package com.ruijixiang.leetcode.everyday.leetcode2024.leetcode202408;

public class leetcode20240820 {

    private static int MX=31;
    private static int[][] c=new int[31][31];

    static{
        for(int i=0;i<MX;i++){
            c[i][0]=c[i][i]=1;
            for(int j=1;j<i;j++){
                c[i][j]=c[i-1][j]+c[i-1][j-1];
            }
        }
    }

    public int waysToReachStair(int k){
        int ans=0;
        for(int i=0;i<30;i++){
            int m=(1<<i)-k;// m个操作一
            if(0<=m && m<=i+1){
                ans+=c[i+1][m];
            }
        }
        return ans;
    }
}
